<?php 
$_FILES;
// var_dump($_FILES);exit;
// // 判断FILES是否为空
// if ($_FILES) {
	
// 	$tmp_name=$_FILES['userfile']['tmp_name'];
// 	$name=$_FILES['userfile']['name'];
	
// 	if (!is_uploaded_file($tmp_name)) exit;
	
// 	$path= './Upload/';
	
// 	is_dir($path) || mkdir($path);
	
// 	$newName=uniqid().substr($name,strrpos($name, '.')) ;
	
// 	$newPath=$path.$newName;
	
// 	move_uploaded_file($tmp_name, $newPath);

// }




$res = array();
foreach ($_FILES['userfile'] as $key => $value)

{
	foreach ($value as $k => $v) {	
		$res[$k][$key] = $v;
	}
}
var_dump($_FILES['userfile']);exit;
//如果是合法上传的话
foreach ($res as $a => $b) {
	// var_dump(  $b['tmp_name']);	
	if(is_uploaded_file($b['tmp_name'])){

		$tmp_name = $b['tmp_name'];
		$name = $b['name']; 
		$path = "./upload/";
		is_dir($path) || mkdir($path);

		$Newname = uniqid().substr($name, strrpos($name,'.'));
		$Newpath =$path.$Newname;

		if(move_uploaded_file($tmp_name, $Newpath)){
			echo "ok";
		}
	}
}

 // var_dump(glob('./Upload/*'));





 ?>